number_dict = {'零': 0, '一': 1, '二': 2, '两': 2, '三': 3, '四': 4, '五': 5, '六': 6,
               '七': 7, '八': 8, '九': 9, '十': 10, '百': 100, '千': 1000, '万': 10000,
               '亿': 100000000}


# 仅支持
def func(num_str):
    res = 0
    unit = 1
    big_unit = 1
    for i in range(len(num_str) - 1, -1, -1):
        new_num = number_dict.get(num_str[i])
        if new_num == 10 and i == 0:  # 十一 ~ 十九
            res = new_num * unit + res
        elif new_num >= 10:
            if big_unit < new_num < unit:
                big_unit = unit
            elif unit < big_unit < new_num:
                big_unit = 1
            unit = new_num
        else:
            res = new_num * unit * big_unit + res
    return res


if __name__ == '__main__':
    str1 = '十一'
    str2 = '五百一十一'
    str3 = '一亿九千六百一十一万零二十三'
    str4 = '九万七千三百六十二亿八千九百三十二万五千二百零一'
    str5 = '五百零一'
    str6 = '九万九千九百九十九亿九千九百九十九万九千九百九十九'
    str7 = '零'
    print(func(str1))
    print(func(str2))
    print(func(str3))
    print(func(str4))
    print(func(str5))
    print(func(str6))
    print(func(str7))
